using Tycho.Parser.Tokens;

namespace Tycho.Parser.Peg {
    public class IdentifierTerminal<Context> : Terminal<Context> {
        protected override ParseResult<Context> ParseTerminal (Token[] tokens, int index, Context context) {
            var token = tokens[index] as IdentifierToken;
            if (token != null) {
                return new ParseResult<Context> (index + 1, new IdentifierTerm (token.Identifier), context);
            } else {
                return null;
            }
        }
    }
}